be65efb0cc7e27e5dddf6b50b4409d97b1d621cd,backend-service/app/models/daos/DatasetInfoDao.java,DatasetInfoDao,updateDatasetCapacity,#JsonNode#,276
Before Change
final JsonNode urnNode = root.path("urn");
final JsonNode capacity = root.path("capacity");
if (auditHeader.isMissingNode() || urnNode.isMissingNode() || capacity.isMissingNode() || !capacity.isArray()) {
throw new IllegalArgumentException(
"Dataset capacity info update fail, " + "Json missing necessary fields: " + root.toString());
}
final String urn = urnNode.asText();
final Long eventTime = auditHeader.path("time").asLong() / 1000; // millisecond to second
final Integer datasetId = Integer.valueOf(DatasetDao.getDatasetByUrn(urn).get("id").toString());
ObjectMapper om = new ObjectMapper();
After Change
final JsonNode urnNode = root.path("urn");
final JsonNode capacity = root.path("capacity");
if ((idNode.isMissingNode() && urnNode.isMissingNode()) || capacity.isMissingNode() || !capacity.isArray()) {
throw new IllegalArgumentException(
"Dataset capacity info update fail, " + "Json missing necessary fields: " + root.toString());
}
final Object[] idUrn = findIdAndUrn(idNode, urnNode);
final Integer datasetId = (Integer) idUrn[0];
final String urn = (String) idUrn[1];
ObjectMapper om = new ObjectMapper();
for (final JsonNode capacityInfo : capacity) {
DatasetCapacityRecord record = om.convertValue(capacityInfo, DatasetCapacityRecord.class);
record.setDatasetId(datasetId);
record.setDatasetUrn(urn);
record.setModifiedTime(System.currentTimeMillis() / 1000);
CAPACITY_WRITER.append(record);
}